import request from '@/utils/request'; //引入request.js
//获取分类
export function getCategory() {
	return request({
		url: 'category',
		method: 'get'
	});
}
//获取全部商品
export function getAllpro() {
	return request({
		url: 'getAllpro',
		method: 'get'
	});
}
//加载更多商品
export function getAllprotomore() {
	return request({
		url: 'getAllprotomore/10',
		method: 'get'
	});
}
//根据id查询商品并保存在用户的足迹中
export function listCommodityAndAdd(goodsId) {
	return request({
		url: `/listCommodityAndAdd/${goodsId}/1`,
		method: 'get'
	});
}

//根据当前商品id查询规格
export function listCommdityguige(goodsId) {
	return request({
		url: `/listCommdityguige/${goodsId}`,
		method: 'get'
	});
}

//获取购物车全部商品
export function GetShoppingCatbyUseid(userId) {
	return request({
		url: `/GetShoppingCatbyUseid/${userId}`,
		method: 'get'
	});
}

//获取商品评论
export function listDiscuss(idx) {
	return request({
		url: `/listDiscuss/${idx}`,
		method: 'get'
	});
}
//根据购物车id改变商品数量
export function updateSPSum(val, idx) {
	return request({
		url: `/updateSPSum`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
		data: {
			commoditysum: val,
			commodityid: idx
		}
	});
}
//删除购物车商品
export function DeleteSP(val, uid) {
	return request({
		url: `/DeleteSP/${val}/${uid}`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
	});
}

//根据订单状态查询商品
export function getSbysanduid(uid, val) {
	return request({
		url: `/getSbysanduid/${uid}/${val}`,
		method: 'get',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
	});
}
//模糊查询商品
export function getCommodityLike(val) {
	return request({
		url: `/getCommodityLike`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
		data: {
			mh: val
		}
	});
}
//添加商品至购物车
export function addShoppingCart(uid, commoditysum, comid, geid) {
	return request({
		url: `/SaveShoppingcat`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
		data: {
			uid: uid,
			commoditysum: commoditysum,
			comid: comid,
			geid: geid
		}
	});
}
//是否收藏
export function getCollectbycomid(uid, idx) {
	return request({
		url: `/getCollectbycomid`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
		data: {
			uid: uid,
			comid: idx
		}
	});
}
//获取收藏
export function getCollect(uid) {
	return request({
		url: `/getCollect/${uid}`,
		method: 'get',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
	});
}
//删除收藏
export function deleteCollect(val) {
	return request({
		url: `/DeleteCollect/${val}`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
	});
}
//获取分类
export function getListclassification() {
	return request({
		url: `/listclassification`,
		method: 'get',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
	});
}
//根据分类id查询商品
export function getCommodityBycaid(idx) {
	return request({
		url: `/getCommodityBycaid/${idx}`,
		method: 'get',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
	});
}
//根据用户id获取用户地址
export function getUaddresslist(uid) {
	return request({
		url: `/Uaddresslist/${uid}`,
		method: 'get',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
	});
}
//根据用户id删除用户地址
export function delUaddress(val) {
	return request({
		url: `/delUaddress/${val}`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
	});
}

//修改用户地址
export function modUaddress(addressData) {
	return request({
		url: `/modUaddress`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
		data: {
			uid: addressData.uid,
			aid: addressData.aid,
			aname: addressData.aname,
			aphone: addressData.aphone,
			address: addressData.address,
			ud1: addressData.ud1,
			ud2: addressData.ud2,
			taddress: addressData.taddress,
			mor: addressData.mor,
			arecode: addressData.arecode,
		}
	});
}


//修改五种商品状态
export function updateStatus(uid, commodityid, state) {
	return request({
		url: `/upstatus`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
		data: {
			uid: uid,
			commodityid: commodityid,
			commodstatus: state
		}
	});
}

//获取购物车数据至结算页
export function getShoppingcatByGW(comId) {
	return request({
		url: `/getShoppingcatByGWC/${comId}`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
	});
}
//支付
export function Buy(uid, commodityid, kid) {
	return request({
		url: `/BuyPr`,
		method: 'post',
		headers: { 'Content-Type': "application/x-www-form-urlencoded" },
		data: {
			uid: uid,
			commodityid: commodityid,
			kid: kid
		}
	});
}







